var express = require('express');
var router = express.Router();

/* GET home page. */
// 渲染登录
router.get('/login', (req, res) => {
  res.render('login');
})
// 做登录判断
router.post('/dologin', (req, res) => {
  let username = req.body.username;
  let password = req.body.password;
  //进行判空
  if (username == '' || password == '' || req.body.yzm == '') {
    res.send('请输入正确的用户名,密码,验证码');
    return;
  };
  if (username != req.session.username || password != req.session.password) {
    res.send(`请输入正确的用户名或密码,点击前往<a href = 'http://localhost:3000/regester'>注册</a>`)
    return;
  } else {
    res.send(`欢迎<h1 style='color:skyblue'>${req.session.username}</h1>回家`)
  }
  
})
module.exports = router;
